﻿/*
 * User: David
 * Date: 29/06/2013
 * Time: 3:10 PM
 * 
 */
using System;
using System.Collections.Generic;
using HockeySimulator.Interfaces;

namespace HockeySimulator.Entities.League
{
	/// <summary>
	/// Description of Divisions.
	/// </summary>
	public class Division:iExportable
	{
		private string Name;
		private List<Team> Teams;
		
		public Division(bool UseDefaultInitialize = false)
		{
			if(UseDefaultInitialize)
				defaultDivisionInitialize();
			else
			{
				Name = "";
				Teams = new List<Team>();
			}
		}
		
		public Division(List<Team> TeamList, string DivisionName = "")
		{
			Name = (DivisionName!= null?DivisionName:"");
			
			if (TeamList.Count >= 0)
			{
				Teams = new List<Team>(TeamList);
			}
			else
			{
				Teams = new List<Team>();
			}
		}
		
		private void defaultDivisionInitialize()
		{
			//This is the default League initialization with 1 default Team
			
			Name = "DefaultDivisionName";
			Teams = new List<Team>();
			
			Teams.Add(new Team());
		}
		
		//Interface method
		
		public string Export()
		{
			string NL = Environment.NewLine;
			
			string result = "Division : " + Name + NL;
			result += "+++++++++++++++++++++++++" + NL;
			
			if (Teams != null)
			{
				if(Teams.Count == 0)
					result += "No team";
				else
				{
					foreach (Team T in Teams)
					{
						result += T.Export() + NL;
						result += "+++++++++++++++++++++++++" + NL;
					}
				}
			}
			else
			{
				result += "No team";
			}
			
			return result;
		}
		
		//Other methods
		
	}
}
